#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
struct ListNode {
	int val;
	struct ListNode* next;
};
int main()
{
	int a = 0;
	scanf("%d", &a);
	struct ListNode* s1 = (struct ListNode*)malloc(sizeof(struct ListNode));
	if (s1 == NULL)
	{
		perror("malloc");
		return 1;
	}
	struct ListNode* s2 = (struct ListNode*)malloc(sizeof(struct ListNode));
	if (s2 == NULL)
	{
		perror("malloc");
		return 1;
	}
	struct ListNode* s3 = (struct ListNode*)malloc(sizeof(struct ListNode));
	if (s3 == NULL)
	{
		perror("malloc");
		return 1;
	}
	struct ListNode* s4 = (struct ListNode*)malloc(sizeof(struct ListNode));
	if (s4 == NULL)
	{
		perror("malloc");
		return 1;
	}
	struct ListNode* s5 = (struct ListNode*)malloc(sizeof(struct ListNode));
	if (s5 == NULL)
	{
		perror("malloc");
		return 1;
	}
	s1->val = 1;
	s2->val = 2;
	s3->val = 3;
	s4->val = 4;
	s5->val = 5;
	s1->next = s2;
	s2->next = s3;
	s3->next = s4;
	s4->next = s5;
	s5->next = NULL;
	struct ListNode* Newhead = NULL; 
	struct ListNode* Newtail = NULL;
	struct ListNode* pcur = s1;
	while (pcur)
	{
		if (pcur->val != a)
		{
			if (Newtail == NULL)
			{
				Newtail = pcur;
			}
			else
			{
				Newtail->next=pcur;
				Newtail = Newtail->next;
			}
		}
		pcur = pcur->next;
		
	}
	struct ListNode* w = s1;
	while (w)
	{
		printf("%d->", w->val);
		w = w->next;
	}
	free(s1);
	free(s2);
	free(s3);
	free(s4);
	free(s5);
	s1 = NULL;
	return 0;
}